package lbsproject.processaudit.adr.global;

import lbsproject.processaudit.misc.SerializableWorker;
import android.app.Application;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;

public class ProcessAuditAndroid extends Application {

	private SerializableWorker worker;

	public SerializableWorker getWorker() {
		return worker;
	}

	public void setWorker( SerializableWorker worker ) {
		this.worker = worker;
	}

	public boolean isNetworkAvailable() {
		ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService( CONNECTIVITY_SERVICE );

		if (connectivityManager == null) {
			return false;
		}

		State mobile = connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_MOBILE ).getState();
		if (mobile.equals( State.CONNECTED )) {
			return true;
		}

		State wifi = connectivityManager.getNetworkInfo( ConnectivityManager.TYPE_WIFI ).getState();
		if (wifi.equals( State.CONNECTED )) {
			return true;
		}

		return false;
	}

	@Override
	public void onCreate() {
		super.onCreate();
	}

}
